<template>
  <div>
    <base-page ref="basePage" :basepage="basePage"></base-page>
    <el-dialog title="操作" :visible.sync="dialogFormVisible" v-dialogDrag append-to-body>
      <el-form :inline="true" :model="row" class="demo-form-inline">
        <el-form-item label="请选择状态">
          <el-select v-model="row.state" placeholder="请选择状态">
            <el-option label="待处理" value="0"></el-option>
            <el-option label="已发货" value="1"></el-option>
            <el-option label="已完成" value="2"></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="define()">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import BasePage from "../BasePage.vue";
export default {
  components: {
    "base-page": BasePage,
  },
  data() {
    return {
      basePage: {
        // URL
        url: "exchangeOperation",
        // 查询条件
        searchConf: [[]],
        buttonConf: {
          insertShow: true,
          deleteShow: true,
        },
        // table列
        tableColumnConf: {
          columns: [
            { prop: "goodName", label: "商品名称" },
            { prop: "spendNum", label: "支付积分" },
            { prop: "phone", label: "收货人电话" },
            { prop: "address", label: "地址" },
            { prop: "userName", label: "兑换人" },
            { prop: "createTime", label: "兑换时间" },
            { prop: "state", label: "state" },
          ],
          operation: {
            detail: false,
            alter: false,
            state: true,
            defs: [
              {
                name: "修改",
                event: "alter",
              },
            ],
          },
        },
        detailConf: {
          title: "",
          data: [],
        },
        // 新增修改form表单设置
        formConf: {
          formData: {},
          width: "50%",
          title: "",
          data: [],
          rules: {},
        },
      },
      dialogFormVisible: false,
      row: {},
    };
  },
  methods: {
    define() {
      this.COMMON.httpPost(
        this,
        "exchangeOperation/updateById",
        this.row,
        (result) => {
          if (result.result === "SUCCESS") {
            if (result.result === "SUCCESS") {
              this.$refs.basePage.getPage();
              this.dialogFormVisible = false;
            }
          }
        },
        (result) => {}
      );
    },
    event(event) {
      switch (event) {
      }
    },
    selectChange(type, pro, value) {},
    operation(row, event) {
      if (event === "alter") {
        this.row.id = row.id;
        this.dialogFormVisible = true;
      }
    },
    formatter(data, prop, index) {
      switch (prop) {
        case "state": {
          if (data === "0") {
            return "待处理";
          }
          if (data === "1") {
            return "已发货";
          }
          if (data === "3") {
            return "已完成";
          }
          break;
        }
        default: {
          return data;
        }
      }
    },
  },
  activated: function () {},
};
</script>
<style>
</style>